package com.aspose.cells;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;

class zhp implements ICellsDataTable {
   String[] a;
   ResultSet b;
   int c;
   int d;

   zhp(ResultSet var1, int var2) {
      try {
         this.b = var1;
         this.c = var1.getRow();
         ResultSetMetaData var3 = var1.getMetaData();
         this.a = new String[var3.getColumnCount()];

         for(int var4 = 1; var4 <= this.a.length; ++var4) {
            this.a[var4 - 1] = var3.getColumnName(var4);
         }

         if (var2 == -1) {
            if (var1.getType() != 1003) {
               var1.last();
               var2 = var1.getRow() - this.c + 1;
               if (this.c == 0) {
                  var1.beforeFirst();
               } else {
                  var1.relative(-var2 + 1);
               }
            } else {
               var2 = 0;
            }
         }

         this.d = var2;
      } catch (Exception var5) {
         throw new CellsException(6, "Invalid result set");
      }
   }

   public String[] getColumns() {
      return this.a;
   }

   public int getCount() {
      return this.d;
   }

   public void beforeFirst() {
      try {
         if (this.b.getType() != 1003) {
            int var1 = this.b.getRow() - this.c;
            if (this.c == 0) {
               this.b.beforeFirst();
            } else {
               this.b.relative(-var1);
            }
         }
      } catch (Exception var2) {
         ;
      }

   }

   public Object get(int index) {
      try {
         return this.b.getObject(index + 1);
      } catch (Exception var3) {
         return null;
      }
   }

   public Object get(String columnName) {
      try {
         return this.b.getObject(columnName);
      } catch (Exception var3) {
         return null;
      }
   }

   public boolean next() {
      try {
         return this.b.next();
      } catch (Exception var2) {
         return false;
      }
   }
}
